﻿using System;
using System.ServiceProcess;

namespace BizElements.Services.Windows
{
    /// <summary>Windows service which hosts the remoting WCF services.</summary>
    internal class RpcWinService : ServiceBase
    {
        /// <summary>Required designer variable.</summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>CTor. Initializes component.</summary>
        public RpcWinService()
        {
            InitializeComponent();
        }

        /// <summary>Clean up any resources being used.</summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        /// <summary>Required method for Designer support - do not modify the contents of this method with the code editor.</summary>
        private void InitializeComponent()
        {
            components = new System.ComponentModel.Container();
            this.ServiceName = RpcServiceInstaller.RpcServiceName;
        }

        /// <summary>Starts remoting services.</summary>
        protected override void OnStart(string[] args)
        {
            RpcWcfServiceManager.Start();
        }

        /// <summary>Stops remoting services.</summary>
        protected override void OnStop()
        {
            RpcWcfServiceManager.Stop();
        }
    }
}
